#ifndef DNSSERVERCONFIGURATION
#define DNSSERVERCONFIGURATION

#include <vector>
#include <string>
#include <stdint.h>
#include "threads.h"

class DnsServerConfiguration{

public:
	DnsServerConfiguration( int argc, char *argv[] );
	virtual ~DnsServerConfiguration();
	void verbose( const std::string &message );
	std::string listenAddress() const;
	uint16_t listenPort() const;
	std::vector< std::string > forwarders() const;
	bool forward() const;



protected:
	void setDefaults();
	void readConfigFile();
	void parseCommandLine( int argc, char *argv[] ); 
	void printHelp();
	void sanitizeConfigLine( std::string &line );
  void trim( std::string &str );
	std::vector<std::string> & split(const std::string &s, char delim, std::vector<std::string> &elems);
	std::vector<std::string> split(const std::string &s, char delim);
		

private:
	Mutex verboseMutex_;
  std::string configFile_; 
	bool verbose_;

	uint16_t listenPort_;
	std::string listenAddress_;
	bool forwarder_;
	std::vector< std::string > forwarders_; //might want to change this to some ip type
	bool purePassiveMode_; //for collecting intelligence only

	//inteligence features
	bool detectFastFlux_; //Fast Flux domains identified based on changes in a given period
	int fastFluxChangesPerPeriod_;
	int fastFluxPeriod_; //in sec 
	//std::vector< std::pair<std::string, DnsRecord> > blacklisting_; //Bad stuff that we shouldn't resolve.
	std::vector< std::string > globalWhiteList_; //Anyone in this list can recurse queries. 
	bool logViolations_; //Log all violations
	std::string violationLog_;
	bool logQueriesToDatabase_;
	std::string databaseHostname_; 
	std::string user_;
	std::string password_; 
	std::string database_;
	//MX records for non mail hosts
	bool monitorMx_;
	bool logMxViolations_; 
	std::vector< std::string > whitelistedMXClients_;
	//NS records for non DNS servers
	bool monitorNs_;
	bool logNSViolations_;
	std::vector< std::string > whitelistedNSClients_;
	//A 
	bool monitorA_;
	bool logAViolations_; 
	std::vector< std::string > whitelistedAClients_;
	//AAAA
	bool monitorAAAA_;
	bool logAAAAViolations_;
	std::vector< std::string > whitelistedAAAAClients_; 
	//PTR records
	bool monitorPTR_;
	bool logPTRViolations_; 
	std::vector< std::string > whitelistedPTRClients_;
	//SVR records (think VoIP)
	bool monitorSVR_;
	bool logSVRViolations_; 
	std::vector< std::string > whitelistedSVRClients_; 
	//CNAME
	bool monitorCNAME_;
	bool logCNAMEViolations_; 
	std::vector< std::string > whitelistedCNAMEClients_; 
	//TEXT
	bool monitorText_;
	bool logTextViolations_; 
	std::vector< std::string > whitelistedTEXTClients_;

	//Security Features
	bool Ox20Encoding_;
	bool randomizeIDs_; //would only want to turn this off for debug purposes
	bool randomizeSourcePorts_; //would only want to turn this off for debuging
	bool dropCachePoisonedEntries_;
	bool relookupCachePoisonedEntries_; //use a hidden DNS server
	bool identifyCachePoisoningPassively_; //sniff DNS traffic to the box to identify cache poisoning.
	std::vector< std::string > alternateDNSServers_; //to check answers against when suspected poisoning
	//DNSSec

	//Performance
	bool prefetching_;
	int cacheMemory_; //in MB



};

#endif
